package org.iteam.core.service.mysql.impl.base;

import java.sql.SQLException;
import java.util.List;

import org.iteam.core.model.base.BaseArea;
import org.iteam.core.service.base.BaseAreaService;

public class BaseAreaServiceImpl extends BaseAreaService {
	@Override
	public List<BaseArea> queryByPage(long page, long rows) throws SQLException {
		String SQL = "SELECT * FROM BASE_AREA ORDER BY NAME LIMIT ?,?";
		return super.query(SQL, (page - 1) * rows, rows);
	}

	@Override
	public List<BaseArea> queryByPage(long page, long rows, String parent)
			throws SQLException {
		if (parent == null || "".equals(parent)) {
			String SQL = "SELECT * FROM BASE_AREA WHERE PID IS NULL ORDER BY NAME   LIMIT ?,?";
			return super.query(SQL, (page - 1) * rows, rows);
		} else {
			String SQL = "SELECT * FROM BASE_AREA WHERE PID = ? ORDER BY NAME   LIMIT ?,?";
			return super.query(SQL, parent, (page - 1) * rows, rows);
		}

	}

}
